package com.atguigu.springcloud.Controller;

import com.atguigu.springcloud.Pojo.Payment;
import com.atguigu.springcloud.ResponseBody.Body;
import com.atguigu.springcloud.ResponseBody.Case;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

@RestController
public class OrderController {

    public static final String PAYMENT_URL="http://CLOUD-PAYMENT-SERVICE";
    

    @Autowired
    public RestTemplate restTemplate;


    @RequestMapping(value = "consumer/addPayment",method = RequestMethod.POST)
    public Body addPayment(@RequestBody Payment payment){
        return restTemplate.postForObject(PAYMENT_URL+"/addPayment", payment,Body.class);
    }
    
    
    @RequestMapping(value = "consumer/queryPayment",method = RequestMethod.GET)
    public Body getPayment(@RequestParam("id") Long id){
        return restTemplate.getForObject(PAYMENT_URL+"/queryPayment?id="+id, Body.class);
    }
}
